//导入http模块
const http = require('http')
// 导入url模块
const url = require('url')

// 创建服务对象
const server = http.createServer((request, response) => {
    // request.url
    console.log(request.url);
    // 解析request.url
    const res = url.parse(request.url, true)
    console.log("🚀🚀🚀 ~ file: 05_提取http报文中的URL和查询字符串.js:12 ~ server ~ res:", res)
    let pathname = res.pathname
    console.log("🚀🚀🚀 ~ file: 05_提取http报文中的URL和查询字符串.js:14 ~ server ~ pathname:", pathname)

    console.log(res.query.name);
    console.log(res.query.password);
    response.setHeader('Content-Type', 'text/html;charset=utf-8')
    // 设置响应体
    response.end('url')
})

// 监听端口，启动服务
server.listen(9000, () => {
    console.log('服务启动成功...')
})